<template>
  <div class="conversation-display">
    <h3 class="conversation-title">对话内容</h3>
    <div class="conversation-container">
      <div v-for="(turn, index) in dialogueTurns" :key="index" class="message-container">
        <div :class="['message', turn.speaker.toLowerCase()]">
          <div class="message-header">
            <span class="speaker">{{ turn.speaker }}</span>
            <span class="turn-number">第 {{ turn.turn }} 轮</span>
          </div>
          <div class="message-content">
            <p>{{ turn.text }}</p>
            <p v-if="turn.subText" class="subtext">暗示: {{ turn.subText }}</p>
          </div>
          <div class="message-emotion" :class="turn.emotion.type">
            <span class="emotion-icon">{{ getEmotionIcon(turn.emotion.type) }}</span>
            <span class="emotion-type">{{ turn.emotion.type }}</span>
            <span class="emotion-intensity">(强度: {{ turn.emotion.intensity }})</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import type { DialogueTurn } from '../../types/analysis';

// Props
defineProps<{
  dialogueTurns: DialogueTurn[];
}>();

// 获取情绪图标
const getEmotionIcon = (type: string): string => {
  const emotionIcons: Record<string, string> = {
    'positive': '😊',
    'negative': '😠',
    'neutral': '😐',
    'surprise': '😲',
    'fear': '😨',
    'sadness': '😢',
    'joy': '😄',
    'anger': '😡',
    'disgust': '🤢'
  };
  
  return emotionIcons[type] || '❓';
};
</script>

<style scoped>
.conversation-display {
  width: 100%;
  margin-bottom: 20px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background-color: #f9f9f9;
  overflow: hidden;
}

.conversation-title {
  font-size: 18px;
  padding: 15px;
  margin: 0;
  background-color: #f0f0f0;
  border-bottom: 1px solid #e0e0e0;
}

.conversation-container {
  max-height: 400px;
  overflow-y: auto;
  padding: 15px;
}

.message-container {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
}

.message {
  max-width: 80%;
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  position: relative;
}

.message.man {
  align-self: flex-start;
  background-color: #e3f2fd;
  border-top-left-radius: 2px;
  margin-right: auto;
}

.message.woman {
  align-self: flex-end;
  background-color: #f3e5f5;
  border-top-right-radius: 2px;
  margin-left: auto;
}

.message-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  font-size: 14px;
}

.speaker {
  font-weight: bold;
  color: #333;
}

.turn-number {
  color: #666;
  font-size: 12px;
}

.message-content {
  margin-bottom: 5px;
}

.message-content p {
  margin: 0 0 5px 0;
  line-height: 1.4;
}

.subtext {
  font-style: italic;
  color: #666;
  font-size: 13px;
}

.message-emotion {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: #666;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px dashed #e0e0e0;
}

.emotion-icon {
  margin-right: 5px;
  font-size: 16px;
}

.emotion-type {
  margin-right: 5px;
  font-weight: bold;
}

.emotion-intensity {
  font-size: 11px;
}

/* 情绪类型的颜色 */
.positive {
  color: #4caf50;
}

.negative {
  color: #f44336;
}

.neutral {
  color: #9e9e9e;
}

.surprise {
  color: #ff9800;
}

.fear {
  color: #9c27b0;
}

.sadness {
  color: #2196f3;
}

.joy {
  color: #ffc107;
}

.anger {
  color: #e91e63;
}

.disgust {
  color: #795548;
}
</style>